//index.js
//获取应用实例
const API = require("../../common/constant.js");
const util = require("../../utils/util");
var app = getApp();
Page({
  data: {
    marks: [],
    comments: [],
    pageIndex: 1
  },
  findReply() {
    util.httpbody({
      url: API.URL.REPLY.FIND_REPLY_INFO,
      data: {
        "pageIndex": this.data.pageIndex,
        "pageSize": 10,
        "userId": this.data.id
      },
      success: res => {
        console.log('res', res)
        let bussData = res.data.bussData;
        let marks = [], comments = []
        bussData.forEach((item, index) => {
          comments.push({
            avatar: bussData[index].attachmentUrl,
            name: bussData[index].nickname,
            sign: bussData[index].content,
            time: bussData[index].gmtCreated
          })
          marks.push(bussData[index].sign)
        })
        this.setData({
          marks: this.data.marks.concat(marks),
          comments: this.data.comments.concat(comments),
          pageIndex: this.data.pageIndex+1
        })
      },
      fail: err => {
        console.log('err', err)
      }
    })
  },
  //事件处理函数
  onLoad(options) {
    console.log(options)
    this.setData({
      id: options.id
    })
    this.findReply()
  }
})
